<template>
  <div>
    <div class="main">
      <!-- <div class="serbox">
        <div class="search">
          <el-input size="medium"
                    placeholder="请输入内容"
                    suffix-icon="el-icon-search"
                    v-model="searchText"
                    @keyup.enter.native="$event.target.blur"
                    @blur="search">
          </el-input>
        </div>
      </div> -->
      <div class="table">
        <div class="tabr">
          <span>序号</span>
          <span>标题</span>
          <span>时间</span>
          <span>操作</span>
        </div>
        <div class="content">
          <div class="el"
               v-for="(item,index) in list"
               :key="item.id">
            <span>{{index+1}}</span>
            <span>{{item.title}}</span>
            <span>{{item.createAt}}</span>
            <span @click="opendet(index)">查看详情</span>
          </div>
        </div>
      </div>
      <div class="page">
        <el-pagination background
                       @current-change="changePage"
                       :current-page.sync="page"
                       :page-size="pageSize"
                       layout="total,prev,pager,next,jumper"
                       :total="total">
        </el-pagination>
      </div>
    </div>
    <div class="dlog">
      <el-dialog title="详情"
                 :visible.sync="noticePop"
                 width="50%">
        <el-form label-width="80px">
          <el-form-item label="标题">
            <div class="elcont">{{not.title}}</div>
          </el-form-item>
          <el-form-item label="内容">
            <div class="elcont"
                 v-html="not.content"></div>
          </el-form-item>
          <el-form-item label="发布人">
            <div class="elcont">{{not.author}}</div>
          </el-form-item>
          <el-form-item label="时间">
            <div class="elcont">{{not.createAt}}</div>
          </el-form-item>
        </el-form>
      </el-dialog>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      searchText: "",
      page: 1,
      pageSize: 10,
      total: 0,
      noticePop: false,
      not: {},
      list: []
    }
  },
  mounted () {
    this.getlist();
  },
  methods: {
    getlist () {
      this.$postRequest("/mall/cmsNoticeSys/list", {
        pageNum: this.page,
        pageSize: this.pageSize
      }).then(res => {
        this.total = res.total;
        this.list = res.rows;
      })
    },
    opendet (index) {
      this.noticePop = true;
      this.not = this.list[index];
    },
    changePage (val) {
      this.getlist();
    }
  }
}
</script>

<style lang="scss" scoped>
.main {
  background: #fff;
  margin: 20px;
  padding: 20px 0;
}
.serbox {
  padding: 0 20px;
  display: flex;
  align-items: center;
  height: 60px;
  .search {
    margin-right: 15px;
  }
}
.table {
  margin: 0 20px;
  border: 1px solid #eee;
  .tabr,
  .el {
    display: flex;
    background: #eee;
    justify-content: space-between;
    span {
      line-height: 40px;
      font-size: 14px;
      text-align: center;
    }
    span:nth-of-type(1) {
      width: 10%;
    }
    span:nth-of-type(2) {
      width: 50%;
    }
    span:nth-of-type(3) {
      width: 20%;
    }
    span:nth-of-type(4) {
      width: 10%;
    }
  }
  .el {
    background: #fff;
    border-top: 1px solid #eee;
    span {
      font-size: 12px;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }
    span:last-child {
      color: #0655ce;
      cursor: pointer;
    }
    span:last-child:hover {
      color: red;
    }
  }
}
.page {
  text-align: right;
  padding: 20px;
}
/deep/ .el-input.is-disabled .el-input__inner,
/deep/ .el-textarea.is-disabled .el-textarea__inner {
  color: #000;
}
</style>